package com.atguigu.eud_teacher.controller;

import java.util.List;

import com.atguigu.commonutils.R;
import com.atguigu.eud_teacher.entity.SubjectEntity;
import com.atguigu.eud_teacher.service.SubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 课程科目
 *
 * @author wuyao
 * @email 13918471632@163.com
 * @date 2021-03-23 12:12:26
 */
@RestController
@RequestMapping("/vue-admin-template/subject")
@CrossOrigin
@Api(tags = "课程分类一二级信息管理和文件上传接口API")
public class SubjectController {
    @Autowired
    private SubjectService subjectService;


    //获取上传过来的文件，把文件读出来

    @ApiOperation(value = "图片上传")
    @PostMapping("/import")
    public R addSubject(MultipartFile file) {
        subjectService.batchImport(file);
        return R.ok();
    }


    //获取二级联动课程下拉框
    @ApiOperation(value = "课程二级联动")
    @GetMapping("/getOneAndTwoSubjects")
    public R getOneAndTwoSubjects() {
        List<SubjectEntity> list = subjectService.getSujectList();
        return R.ok().data("oneSubjectAndTwoSubjects", list);
    }
}
